<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('教师管理')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>课程：</p>
                                <select name="courseId" required>
                                    <option value="">所有</option>
                                    <option th:each="course:${courses}" th:value="${course.courseId}" th:text="${course.courseName}" th:selected="${course.flag}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "mgr/teacher";

        $(function() {
            var options = {
                url: prefix + "/list",
                modalName: "教师管理",
                columns: [
                    {
                        checkbox: true
                    },
                {
                    field : 'teacherId',
                    title : '教师id',
                    visible: false
                },
                {
                    field : 'teacherName',
                    title : '教师',
                    align: 'center'
                },
                {
                    field : 'courseName',
                    title : '课程',
                    align: 'center'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="view(\'' + row.teacherId + '\')"><i class="fa fa-edit"></i>查看班级</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function view(teacherId) {
            var url = prefix + '/view/' + teacherId;
            $.modal.openTab("所带班级", url);
        }

    </script>
</body>
</html>